<?php

require_once '../../config/config.inc.php';
require_once _PS_ROOT_DIR_.'/init.php';

if (!is_array($_POST) || !isset($_POST['DATA']) || !strlen($_POST['DATA']))
	Tools::redirect('');

$response = $_POST['DATA'];

$dir = rtrim(dirname(__FILE__), '/');
$module = explode('/', $dir);
$module = $module[count($module)-1];
require_once $dir.'/'.$module.'.php';
$Module = new $module();

$Response = $Module->decryptResponse($response);
$Response->origin = 'client_return';
if ($Module->processResponse($Response, $Customer, $Order)) {
	Tools::redirect('order-confirmation.php?key='.urlencode($Order->secure_key).'&id_module='.$Module->id.'&id_cart='.$cart->id);
} else {
	if (Validate::isLoadedObject($cart) && ($cart->nbProducts() > 0)) {
		Tools::redirect('order.php?step=3');
	} else {
		Tools::redirect('');
	}
}

?>